<?php

namespace App\Service;

use App\Model\ConfigHouseKeeperModel;
use App\Model\ConfigHouseModel;
use App\Model\DeliveryModel;
use App\Model\OwnerInfoModel;
use App\Model\OwnerShareInfoModel;
use App\Model\UserAddressModel;
use App\Model\UserCarModel;
use App\Model\UserFamilyModel;
use App\Model\UserHouseModel;
use App\Model\UserModel;
use App\Model\UserParkModel;
use App\Utility\Password;
use EasySwoole\HttpClient\Exception\InvalidUrl;
use EasySwoole\HttpClient\HttpClient;
use EasySwoole\Mysqli\Exception\Exception;
use Throwable;

class UserService extends BaseService
{
    /**
     * @param $code
     * @return array
     * @throws Exception
     * @throws InvalidUrl
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function getWechatOpenId($code): array
    {
        $url = 'https://api.weixin.qq.com';
        $appid = ConfigService::getInstance()->getSys('weappid', 'wechat');
        $secret = ConfigService::getInstance()->getSys('wesecret', 'wechat');
        $uri = $url . '/sns/jscode2session?appid=' . $appid . '&secret=' . $secret . '&js_code=' . $code . '&grant_type=authorization_code';
        $client = new HttpClient();
        $client->setUrl($uri);
        $response = $client->get();
        $result = $response->json(true);
        if (isset($result['openid'])) {
            return [
                'result' => true,
                'msg' => '获取成功',
                'data' => $result['openid']
            ];
        } else {
            return [
                'result' => false,
                'msg' => $result['errmsg'] ?? '获取失败'
            ];
        }
    }

    /**
     * @param $code
     * @return array
     * @throws Exception
     * @throws InvalidUrl
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function getWechatPhone($code): array
    {
        $url = 'https://api.weixin.qq.com';
        $access_token = $this->getWechatToken();
        if ($access_token == '获取失败') return ['result' => false, 'msg' => '获取失败'];

        $uri = $url . '/wxa/business/getuserphonenumber?access_token=' . $access_token;
        $param = [
            'code' => $code,
            'access_token' => $access_token
        ];

        $client = new HttpClient($uri);
        $client->setUrl($uri);
        $client->setQuery($param);
        $response = $client->post($param);
        $result = $response->getBody();

        if ($result['errcode'] == 0) {
            return [
                'result' => true,
                'msg' => '获取成功',
                'data' => $result['phone_info']
            ];
        } else {
            return [
                'result' => false,
                'msg' => '获取失败'
            ];
        }
    }

    /**
     * @return array|string
     * @throws Exception
     * @throws InvalidUrl
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function getWechatToken()
    {
        $url = 'https://api.weixin.qq.com/';
        $appid = ConfigService::getInstance()->getSys('weappid', 'wechat');
        $secret = ConfigService::getInstance()->getSys('wesecret', 'wechat');
        $uri = $url . 'cgi-bin/token?grant_type=client_credential&appid=' . $appid . '&secret=' . $secret;

        $client = new HttpClient();
        $client->setUrl($uri);
        $response = $client->get();
        $result = $response->json(true);
        return $result['access_token'] ?? '获取失败';
    }

    /**
     * @param $uid
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function getInfo($uid): array
    {
        $user = UserModel::create()->getUser(['id' => $uid]);
        if (!$user) {
            return [
                'result' => false,
                'msg' => '该账号已注销'
            ];
        }

        $data = [
            'id' => $user->id,
            'userid' => $user->userid,
            'phone' => $user->phone,
            'username' => $user->username,
            'avatar' => $user->avatar,
            'house' => $user->house,
            'type' => $user->type,
            'sex' => $user->sex,
            'login_time' => $user->login_time,
            'login_ip' => $user->login_ip
        ];

        return [
            'result' => true,
            'msg' => '获取成功',
            'data' => $data
        ];
    }

    /**
     * @param $uid
     * @param $username
     * @param $avatar
     * @param $sex
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function editInfo($uid, $username, $avatar, $sex): array
    {
        $user = UserModel::create()->getUser(['id' => $uid]);
        if (!$user) {
            return [
                'result' => false,
                'msg' => '该账号已注销'
            ];
        }

        $par = [
            'username' => $username ?? $user->username,
            'avatar' => $avatar ?? $user->avatar,
            'sex' => $sex ?? $user->sex
        ];

        $res = UserModel::create()->update($par, ['id' => $uid]);
        if (!$res) {
            return [
                'result' => false,
                'msg' => '修改失败'
            ];
        }

        return [
            'result' => true,
            'msg' => '修改成功',
            'data' => 'success'
        ];
    }

    /**
     * @param $uid
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function getHouse($uid): array
    {
        $houses = UserHouseModel::create()->where(['uid' => $uid, 'is_deleted' => 0, 'status' => 1])->all();
        if (empty($houses)) {
            return [
                'result' => false,
                'msg' => '暂无数据'
            ];
        }

        $data = [];
        foreach ($houses as $key => $house) {
            if ($house['default']) $default = $house['id'];
            $data[] = [
                'id' => $house['id'],
                'house' => ConfigService::getInstance()->getHouse($house['village'], $house['unit'], $house['floor'], $house['house']),
                'name' => $house['name'],
                'type' => $house['type'],
                'type_value' => ConfigService::getInstance()->houseType($house['type']),
                'default' => $house['default'],
                'status' => $house['status'],
                'time' => date('Y-m-d', $house['create_time']),
                'disabled' => $house['default']
            ];
        }

        return [
            'result' => true,
            'msg' => '获取成功',
            'data' => [
                'default' => $default ?? 0,
                'data' => $data
            ]
        ];
    }

    /**
     * @param $uid
     * @param $name
     * @param $village
     * @param $unit
     * @param $floor
     * @param $house
     * @param $type
     * @return array
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function editHouse($uid, $name, $village, $unit, $floor, $house, $type): array
    {
        $par = [
            'uid' => $uid,
            'name' => $name,
            'village' => $village,
            'unit' => $unit,
            'floor' => $floor,
            'house' => $house,
            'type' => $type,
        ];

        $s = UserHouseModel::create()->getUser($par);
        if ($s) {
            return [
                'result' => false,
                'msg' => '已提交，请等待审核！'
            ];
        }

        $res = UserHouseModel::create()->addUser($par);
        if (!$res) {
            return [
                'result' => false,
                'msg' => '提交失败'
            ];
        }

        return [
            'result' => true,
            'msg' => '提交成功',
            'data' => 'success'
        ];
    }

    /**
     * @param $uid
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function getPark($uid): array
    {
        $parks = UserParkModel::create()->where(['is_deleted' => 0, 'uid' => $uid])->all();
        if (empty($parks)) {
            return [
                'result' => false,
                'msg' => '暂无数据'
            ];
        }

        $data = [];
        foreach ($parks as $park) {
            $data[] = [
                'id' => $park['id'],
                'park' => ConfigService::getInstance()->getPark($park['park']),
                'name' => $park['name'],
                'start_time' => date("Y-m-d", $park['start_time']),
                'end_time' => $park['end_time'] == 0 ? '永久' : date("Y-m-d", $park['end_time']),
                'type' => $park['type']
            ];
        }


        return [
            'result' => true,
            'msg' => '获取成功',
            'data' => $data
        ];
    }

    /**
     * @param $uid
     * @param $park
     * @param $name
     * @param $tel
     * @param $id_card
     * @param $number
     * @param $image
     * @param $type
     * @param $brand
     * @param $model
     * @param $cid
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function editCar($uid, $park, $name, $tel, $id_card, $number, $image, $type, $brand, $model, $cid): array
    {
        $par = [
            'uid' => $uid,
            'park' => $park,
            'name' => $name,
            'tel' => $tel,
            'id_card' => $id_card,
            'number' => $number,
            'image' => $image,
            'type' => $type,
            'brand' => $brand,
            'model' => $model
        ];

        if ($cid == 0) {
            $res = UserCarModel::create()->addUser($par);
        } else {
            $res = UserCarModel::create()->update($par, ['uid' => $uid, 'id' => $cid]);
        }

        if (!$res) {
            return [
                'result' => false,
                'msg' => '提交失败'
            ];
        }

        return [
            'result' => true,
            'msg' => '提交成功',
            'data' => 'success'
        ];
    }

    /**
     * @param $uid
     * @param $status
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function getCar($uid, $status): array
    {
        $where = ['is_deleted' => 0, 'uid' => $uid];
        if ($status != 99) {
            $where['status'] = $status;
        }

        $cars = UserCarModel::create()->where($where)->all();
        if (empty($cars)) {
            return [
                'result' => false,
                'msg' => '暂无数据'
            ];
        }

        $house = '暂无房产';

        $houses = $this->getDefaultHouse($uid);
        if ($houses['result']) {
            $house = $houses['data']['house'];
        }

        $data = [];
        foreach ($cars as $car) {
            $data[] = [
                'id' => $car['id'],
                'park' => $car['park'],
                'park_value' => ConfigService::getInstance()->getPark($car['park']),
                'image' => $car['image'],
                'name' => $car['name'],
                'tel' => $car['tel'],
                'id_card' => $car['id_card'],
                'number' => $car['number'],
                'type' => $car['type'],
                'type_value' => ConfigService::getInstance()->carType($car['type']),
                'status_label' => ConfigService::getInstance()->getCarStatus($car['status']),
                'brand' => $car['brand'],
                'model' => $car['model'],
                'house' => $house,
                'status' => $car['status']
            ];
        }

        return [
            'result' => true,
            'msg' => '获取成功',
            'data' => $data
        ];
    }

    /**
     * @param $uid
     * @param $id
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function delCar($uid, $id): array
    {
        $res = UserCarModel::create()->update(['is_deleted' => 1], ['id' => $id, 'uid' => $uid]);
        if (!$res) {
            return [
                'result' => false,
                'msg' => '操作失败'
            ];
        }

        return [
            'result' => true,
            'msg' => '操作成功'
        ];
    }

    /**
     * @param $uid
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function getFloor($uid): array
    {
        $houses = UserHouseModel::create()->where(['uid' => $uid, 'is_deleted' => 0])->all();
        if (empty($houses)) {
            return [
                'result' => false,
                'msg' => '暂无数据'
            ];
        }

        $status = 0;

        $data = [];
        foreach ($houses as $key => $house) {
            if ($house['status'] == 0) {
                continue;
            }
            $status = 1;
            if ($house['default']) $default = $house['id'];
            $data[] = [
                'id' => $house['id'],
                'name' => ConfigService::getInstance()->getHouse($house['village'], $house['unit'], $house['floor'], $house['house'])
            ];
        }
        if ($status == 1) {
            return [
                'result' => true,
                'msg' => '获取成功',
                'data' => $data
            ];
        } else {
            return [
                'result' => false,
                'msg' => '等待审核'
            ];
        }

    }

    /**
     * @param $uid
     * @param $hid
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function defaultHouse($uid, $hid): array
    {
        $res = UserHouseModel::create()->update(['default' => 0], ['uid' => $uid]);
        if (!$res) {
            return [
                'result' => false,
                'msg' => '操作失败'
            ];
        }

        $res1 = UserHouseModel::create()->update(['default' => 1], ['uid' => $uid, 'id' => $hid]);
        if (!$res1) {
            return [
                'result' => false,
                'msg' => '操作失败'
            ];
        }
        return [
            'result' => true,
            'msg' => '操作成功',
            'data' => 'success'
        ];

    }

    /**
     * @param $uid
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function getDefaultHouse($uid): array
    {
        $house = UserHouseModel::create()->getUser(['uid' => $uid, 'default' => 1]);
        if (!$house) {
            return [
                'result' => false,
                'msg' => '暂无房产信息'
            ];
        }
        $house = $house->toArray();
        $data = [
            'id' => $house['id'],
            'house' => ConfigService::getInstance()->getHouse($house['village'], $house['unit'], $house['floor'], $house['house']),
            'name' => $house['name'],
            'type' => $house['type'],
            'type_value' => ConfigService::getInstance()->houseType($house['type']),
            'default' => $house['default'],
            'status' => $house['status'],
            'time' => date('Y-m-d', $house['create_time']),
            'disabled' => $house['default']
        ];

        return [
            'result' => true,
            'msg' => '获取成功',
            'data' => $data
        ];
    }

    /**
     * 自动匹配绑定房屋
     * @param $uid
     * @param $tel
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function bindHouse($uid, $tel): bool
    {
        $user = UserModel::create()->getUser(['id' => $uid]);
        if (!$user) return false;
        if ($user->house !== '') return false;
        $h = OwnerInfoModel::create()->getOwner(['tel' => $tel]);
        $status = 0;
        $hos = OwnerInfoModel::create()->where(['tel' => $tel])->all();
        if (empty($hos)) {
            $hos = OwnerShareInfoModel::create()->where(['tel' => $tel])->all();
            if (empty($hos)) return false;
            $status = 1;
        }

        $res = $res1 = false;
        foreach ($hos as $h) {
            $string = $h['project'] . $h['region'] . $h['build'] . '号楼' . $h['unit'] . '单元' . $h['house'] . '室';

            $village = ConfigHouseModel::create()->getConfig(['nid' => 0, 'name' => $h['project'] . $h['region']]);
            $where1 = $village->id ? ['nid' => $village->id, 'name' => $h['build'] . '号楼'] : ['name' => $h['build'] . '号楼'];
            $unit = ConfigHouseModel::create()->getConfig($where1);
            $where2 = $unit->id ? ['nid' => $unit->id, 'name' => $h['unit'] . '单元'] : ['name' => $h['unit'] . '单元'];
            $floor = ConfigHouseModel::create()->getConfig($where2);
            $where3 = $floor->id ? ['nid' => $floor->id, 'name' => $h['house'] . '室'] : ['name' => $h['house'] . '室'];
            $house = ConfigHouseModel::create()->getConfig($where3);

            $res = UserModel::create()->update(['house' => $string, 'type' => 1], ['id' => $uid]);

            $data = [
                'village' => $village->id ?? 0,
                'unit' => $unit->id ?? 0,
                'floor' => $floor->id ?? 0,
                'house' => $house->id ?? 0,
                'name' => $h['name'],
                'default' => 1,
                'uid' => $uid,
                'status' => $status
            ];

            $res1 = UserHouseModel::create()->addUser($data);

            if ($status == 0) {
                $res2 = OwnerInfoModel::create()->update(['uid' => $uid], ['tel' => $tel]);
            } else {
                $res2 = OwnerShareInfoModel::create()->update(['uid' => $uid], ['tel' => $tel]);
            }
        }

        if (!$res || !$res1) return false;
        return true;
    }

    /**
     * @param $uid
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    public function getCaller($uid): array
    {
        $house = UserHouseModel::create()->where(['uid' => $uid, 'status' => 1])->all();
        $caller = [];
        if (!empty($house)) {
            $unit = array_column($house, 'unit');
            $caller = ConfigHouseKeeperModel::create()->where("unit", $unit, 'IN')->all(['is_deleted' => 0]);
        }

        $list = ConfigHouseKeeperModel::create()->where(['type' => 0])->all(['is_deleted' => 0]);

        $callers = array_merge($list, $caller);
        $data = [];

        foreach ($callers as $item) {
            $data[] = [
                'id' => $item['id'],
                'name' => $item['name'],
                'icon' => $item['icon'],
                'type' => $item['type'],
                "type_value" => $item['type'] == 1 ? "区管" : "公共",
                'tel' => $item['tel'],
                'unit' => ConfigService::getInstance()->getKeeperA($item['unit']),
                'star' => $item['star'],
                'comment' => $item['comment']
            ];
        }

        return [
            'result' => true,
            'msg' => '获取成功',
            'data' => $data
        ];
    }

    /**
     * @param $sid
     * @param $password
     * @param $new_password
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    function changePass($sid, $password, $new_password): array
    {
        $user = UserModel::create()->getUser(['id' => $sid]);
        if (!$user) {
            return [
                'result' => false,
                'msg' => '该用户不存在或已注销'
            ];
        }

        if (!Password::getInstance()->validate($password, $user->password ?? '123456')) {
            return [
                'result' => false,
                'msg' => '账户密码不匹配'
            ];
        }

        $newP = Password::getInstance()->encryption($new_password);
        $res = UserModel::create()->update(['password' => $newP], ['id' => $sid]);
        if (!$res) {
            return [
                'result' => false,
                'msg' => '系统错误，请稍后重试'
            ];
        }

        return [
            'result' => true,
            'msg' => '修改成功',
            'data' => 'success'
        ];
    }

    /**
     * @param $uid
     * @return array
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    function getAddress($uid): array
    {
        $address = UserAddressModel::create()->where(['uid' => $uid, 'is_deleted' => 0])->order('label', 'desc')->all();
        $data = [];
        foreach ($address as $add) {
            $address = json_decode($add['address'], true);
            $add['address'] = ConfigService::getInstance()->getCity($address[0]) . ConfigService::getInstance()->getCity($address[1]) . ConfigService::getInstance()->getCity($address[2]);
            $data[] = $add;
        }
        if (empty($data)) {
            return [
                'result' => false,
                'msg' => '暂未添加收货地址'
            ];
        }

        return [
            'result' => true,
            'msg' => '获取成功',
            'data' => $data
        ];
    }

    /**
     * @param $uid
     * @param string $data
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    function editAddress($uid, string $data): array
    {
        $data = json_decode($data, true);
        $rid = $data['id'];
        $data['uid'] = $uid;
        $data['address'] = json_encode($data['address']);
        $addressId = 0;
        if ($data['label'] == 1) {
            UserAddressModel::create()->update(['label' => 0], ['uid' => $uid]);
        }
        if ($rid == 0) {
            unset($data['id']);
            //check
            if (!(preg_match("/^(13[0-9]|14[5|6|7|8|9]|15[0|1|2|3|5|6|7|8|9]|16[2|5|6|7]|17[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9]|19[0|1|2|3|5|6|7|8|9])\d{8}$/", $data['phone']))) {
                return [
                    'result' => false,
                    'msg' => '手机号码不正确'
                ];
            }
            $addressId = UserAddressModel::create()->addUser($data);
            if (!$addressId) {
                return [
                    'result' => false,
                    'msg' => '收货地址添加失败，请稍后重试'
                ];
            }
        } else {
            $address = UserAddressModel::create()->update($data, ['id' => $rid]);
            if (!$address) {
                return [
                    'result' => false,
                    'msg' => '收货地址修改失败，请稍后重试'
                ];
            }
        }
        if ($data['label'] == 1) {
            return $this->editAddressLabel($uid, $rid == 0 ? $addressId : $rid);
        }
        return [
            'result' => true,
            'msg' => '收货地址修改成功',
            'data' => $data
        ];
    }

    /**
     * @param $uid
     * @param $rid
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    function delAddress($uid, $rid): array
    {
        $address = UserAddressModel::create()->getUser(['id' => $rid, 'uid' => $uid, 'is_deleted' => 0]);
        if (!$address) {
            return [
                'result' => false,
                'msg' => '改地址不存在'
            ];
        }
        $res = UserAddressModel::create()->update(['is_deleted' => 1], ['id' => $rid, 'uid' => $uid]);
        if (!$res) {
            return [
                'result' => false,
                'msg' => '收货地址删除失败，请稍后重试'
            ];
        }
        return [
            'result' => true,
            'msg' => '修改成功',
            'data' => ''
        ];
    }

    /**
     * @param $uid
     * @param $rid
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    function editAddressLabel($uid, $rid): array
    {
        $address = UserAddressModel::create()->all(['uid' => $uid]);
        if (!$address) {
            return [
                'result' => false,
                'msg' => '暂未添加收货地址'
            ];
        } else {
            UserAddressModel::create()->update(['label' => 0], ['uid' => $uid]);
        }

        $res = UserAddressModel::create()->update(['label' => 1], ['id' => $rid]);
        if (!$res) {
            return [
                'result' => false,
                'msg' => '收货地址修改失败，请稍后重试'
            ];
        }
        return [
            'result' => true,
            'msg' => '修改成功',
            'data' => ''
        ];
    }

    /**
     * @param $uid
     * @param $name
     * @param $tel
     * @param $type
     * @return array
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    function family($uid, $name, $tel, $type): array
    {
        $user = UserModel::create()->where('type', 0, '<>')->getUser(['phone' => $tel]);
        if ($user) {
            return [
                'result' => false,
                'msg' => '该用户已存在'
            ];
        }

        $par = [
            'uid' => $uid,
            'name' => $name,
            'tel' => $tel,
            'type' => $type
        ];

        $res = UserFamilyModel::create()->addUser($par);
        if (!$res) {
            return [
                'result' => false,
                'msg' => '操作失败，请稍后重试'
            ];
        }
        return [
            'result' => true,
            'msg' => '修改成功',
            'data' => ''
        ];
    }

    /**
     * @param $uid
     * @return array
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    function getFamily($uid): array
    {
        $list = UserFamilyModel::create()->where(['is_deleted' => 0, 'uid' => $uid])->all();
        if (empty($list)) {
            return [
                'result' => false,
                'msg' => '暂无数据'
            ];
        }

        return [
            'result' => true,
            'msg' => '获取成功',
            'data' => $list
        ];
    }

    /**
     * @param $uid
     * @param $id
     * @return array
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    function delFamily($uid, $id): array
    {
        $family = UserFamilyModel::create()->getUser(['id' => $id]);
        $res = UserFamilyModel::create()->update(['is_deleted' => 1], ['uid' => $uid, 'id' => $id]);
        if (!$res) {
            return [
                'result' => false,
                'msg' => '操作失败'
            ];
        }

        $r = UserModel::create()->where(['phone' => $family->tel])->update(['type' => 0]);
        return [
            'result' => true,
            'msg' => '操作成功',
            'data' => 'success'
        ];
    }

    /**
     * @param $uid
     * @return array
     * @throws Throwable
     * @throws \EasySwoole\ORM\Exception\Exception
     */
    function submitDeliveryRead($uid): array
    {
        $res = DeliveryModel::create()->addUser(['uid' => $uid]);
        if (!$res) {
            return [
                'result' => false,
                'msg' => '系统错误'
            ];
        }

        return [
            'result' => true,
            'msg' => '操作成功',
            'data' => 'success'
        ];
    }
}